<!-- inc:head -->
<div id="body">
	<div id="left">
		<div id="user_cp"><div class="loading"></div></div>
		<div class="block-title" style="margin-top:5px;">推荐产品</div>
		<div class="block-msg">
			<ul>
				<!-- run:$list = phpok('vouch','cs=products') -->
				<!-- $list[rslist] AS $key=>$value -->
				<li style="padding-left:40px;"><a href="{:msg_url($value)}"{if($value[id] == $rs[id])} style="color:red;"{end}>{:$value[title]}</a></li>
				<!-- end -->
				<!-- run:unset($list) -->
			</ul>
		</div>
	</div>
	<div id="right">
		<div style="display:none;"><form method="post" action="{:site_url('checkout')}" onsubmit="return to_checkout('{if($rslist)}1{else}0{end}');"></div>
		<!-- if($rslist) -->
		<div class="block-title">购物车</div>
		<div class="block-msg">
			<div style="background:#97BEF4;">
			<table width="100%" cellspacing="1">
			<tr bgcolor="#DCE9FA">
				<th align="center">产品名称</th>
				<th width="60px" align="center">价格</th>
				<th width="100px" align="center">单价</th>
				<th width="45px" align="center">删除</th>
			</tr>
			<!-- $rslist AS $key=>$value -->
			<tr bgcolor="#FFFFFF">
				<td>&nbsp;<img src="images/default/lead.gif" /> {:$value[title]}</td>
				<td class="red" align="center">
					<img src="images/default/minus.gif" class="hand" onclick="cart_minus('{:$value[id]}',{:$value[amount]});" />
					&nbsp;{:$value[amount]}&nbsp;
					<img src="images/default/plus.gif" class="hand" onclick="cart_plus('{:$value[id]}',{:$value[amount]});" />
				</td>
				<td align="center">{:sys_format_price($value[price])}</td>
				<td align="center"><img src="images/default/del.gif" class="hand" onclick="cart_del('{:$value[id]}');" /></td>
			</tr>
			<!-- end -->
			<tr bgcolor="#DCE9FA">
				<td colspan="4">
					<table width="100%">
					<tr>
						<td><button onclick="history.back();" type="button" class="btn" title="返回上一页"><span><span>返回上一页</span></span></button></td>
						<td align="right">产品总价：&nbsp;{:sys_format_price($total_price)}</td>
					</tr>
					</table>
				</td>
			</tr>
			</table>
			</div>
		</div>
		<!-- else -->
		<div class="block-title">您要购物的产品</div>
		<div class="block-msg">
			<table width="100%">
			<tr>
				<td width="120px" align="right"><span class="red">*</span> 产品名称：</td>
				<td><input type="text" id="product_name" name="product_name" class="long_input" /></td>
			</tr>
			<tr>
				<td align="right"><span class="red">*</span> 产品数量：</td>
				<td><input type="text" id="product_amount" name="product_amount" class="short_input" value="1" /></td>
			</tr>
			<tr>
				<td align="right"><span class="red">*</span> 产品单价：</td>
				<td><input type="text" id="product_price" name="product_price" class="short_input" /> 请填写产品单价，总价为：单价 × 数量</td>
			</tr>
			</table>
		</div>
		<!-- end -->
		<div class="space"></div>
		<div class="block-title">收货人信息</div>
		<div class="block-msg">
			<table width="100%">
			<tr>
				<td width="120px" align="right"><span class="red">*</span> 姓名：</td>
				<td><input type="text" id="fullname" name="fullname" /> 请填写收货人的姓名</td>
			</tr>
			<tr>
				<td align="right"><span class="red">*</span> 电话：</td>
				<td><input type="text" id="tel" name="tel" /> 请填写收货人的联系电话</td>
			</tr>
			<tr>
				<td align="right">手机：</td>
				<td><input type="text" id="mobile" name="mobile" /> 请填写收货人的手机号</td>
			</tr>
			<tr>
				<td align="right">&nbsp;</td>
				<td>固定电话或手机号码至少要填写一个，以方便客服与您取得联系</td>
			</tr>
			<tr>
				<td align="right"><span class="red">*</span> 地址：</td>
				<td><input type="text" id="address" name="address" class="long_input" /> 填写收货人的详细地址</td>
			</tr>
			<tr>
				<td align="right"><span class="red">*</span> 邮编：</td>
				<td><input type="text" id="zipcode" name="zipcode" class="short_input" /> 请填写邮编号码</td>
			</tr>
			<tr>
				<td align="right">备注：</td>
				<td><textarea class="long_input" name="note" id="note" style="height:65px;"></textarea></td>
			</tr>
			<tr>
				<td align="right" valign="top">说明：</td>
				<td class="red">如果您给朋友购买商品，请在备注里填上您的姓名及联系手机（电话）<br />我们推荐您注册成为我们的会员后再购买商品<br />这样子您可以在个人中心看到您的订单信息</td>
			</tr>
			<tr>
				<td align="right"><span class="red">*</span> Email：</td>
				<td><input type="text" id="email" name="email" /> 请填写您的邮箱</td>
			</tr>
			</table>
		</div>
		<div class="space"></div>
		<div align="right"><input type="submit" id="_phpok_submit" value="确认购买" /></div>
		</form>
	</div>
	<div class="space clear"></div>
</div>
<script type="text/javascript">
func_php("usercp",js_usercp,"user_cp");

//购物车里的其他相关信息
function cart_minus(id,amount)
{
	if(amount<2)
	{
		alert("产品数量小于2个，不能执行此操作，如果您不需要此产品，请删除！");
		return false;
	}
	var namount = amount - 1;
	var url = base_url + base_func + "=ajax_update&id="+id+"&amount="+namount.toString();
	var msg = get_ajax(url);
	if(msg == "ok")
	{
		window.location.href = window.location.href;
	}
	else
	{
		if(!msg) msg = "error";
		alert(msg);
		return false;
	}
}
function cart_plus(id,amount)
{
	var namount = amount + 1;
	var url = base_url + base_func + "=ajax_update&id="+id+"&amount="+namount.toString();
	var msg = get_ajax(url);
	if(msg == "ok")
	{
		window.location.href = window.location.href;
	}
	else
	{
		if(!msg) msg = "error";
		alert(msg);
		return false;
	}
}
function cart_del(id)
{
	var url = base_url + base_func + "=ajax_del&id="+id;
	var msg = get_ajax(url);
	if(msg == "ok")
	{
		window.location.href = window.location.href;
	}
	else
	{
		if(!msg) msg = "error";
		alert(msg);
		return false;
	}
}

function to_checkout(cart)
{
	if(cart == "0")
	{
		var pro_title = getid("product_name").value;
		var amount = getid("product_amount").value;
		var price = getid("product_price").value;
		if(!pro_title)
		{
			alert("产品名称不允许为空");
			return false;
		}
		if(!amount || parseInt(amount)<1)
		{
			alert("产品数量不能小于1");
			return false;
		}
		if(!price)
		{
			alert("价格不允许为空！");
			return false;
		}
	}
	//联系人信息
	var fullname = getid("fullname").value;
	if(!fullname)
	{
		alert("收货人姓名不允许为空");
		return false;
	}
	var tel = getid("tel").value;
	var mobile = getid("mobile").value;
	if(!tel && !mobile)
	{
		alert("电话和手机至少要填写一个，以方便客服与您取得联系");
		return false;
	}
	var addr = getid("address").value;
	if(!addr)
	{
		alert("地址信息不能为空，如果您购买的是虚拟产品，请填写您的邮箱");
		return false;
	}
	var zipcode = getid("zipcode").value;
	if(!zipcode)
	{
		alert("邮编不允许为空，如您购买的是虚拟产品，请填写：123456");
		return false;
	}
	var email = getid("email").value;
	if(!email)
	{
		alert("邮箱不允许为空！");
		return false;
	}
	var str_reg=/^\w+((-\w+)|(\.\w+))*\@{1}\w+\.{1}\w{2,4}(\.{0,1}\w{2}){0,1}/ig;
	if(email.search(str_reg) == -1)
	{
		alert("邮箱格式不正确！");
		return false;
	}
	getid("_phpok_submit").disabled = true;
	return true;
}
</script>
<!-- inc:foot -->